<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 
        方式一:object构造函数模式
                *套路:先创建空0bject对象，再动态添加属性/方法
                *适用场景:起始时不确定对象内部数据
                *问题:语句太多
     -->
     <script>
        // 一个人：name:'Tom',age:12
        var p = new Object()
        p.name = 'Tom'
        p.age = 12
        p.setName = function(name){
            this.name = name
        }

        // 测试
        p.setName('jack')
        console.log(p.name,p.age);
     </script>
</body>
</html>